package chapter03;

public class MatrixMultiply {
    public static void main(String[] args) {
        int[][] a={{1,1,1},{2,2,2}};
        int[][] b={{1,1},{2,2},{3,3}};
    
        MatrixMultiply matrix = new MatrixMultiply();
        matrix.matrixMutiply(a,b);


    }
    public  static  int[][] matrixMutiply(int[][] a, int[][] b) {
        if (a[0].length != b.length)
            throw new IllegalArgumentException("矩阵不可连乘");
        int[][] c = new int[a.length][b[0].length];
        for (int i = 0; i < a.length; i++) {                 //a的行数
            for (int j = 0; j < b[0].length; j++) {        //b的列数
                int sum = a[i][0] * b[0][j];
                for (int k = 1; k < a[0].length; k++) {  //a的列数
                    sum += a[i][k] * b[k][j];
                }
                c[i][j] = sum;
                System.out.println(":=="+sum);

            }
        }
        return c;
    }
}
